package com.gmail.blackdog1987.carcare.widget;

import in.srain.cube.image.CubeImageView;
import in.srain.cube.image.ImageLoader;
import in.srain.cube.image.ImageLoaderFactory;
import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.view.Window;
import android.widget.Toast;

import com.gmail.blackdog1987.carcare.App;
import com.gmail.blackdog1987.carcare.BaseActivity;
import com.gmail.blackdog1987.carcare.R;

/**
 * 照片选择
 * 
 * @author 董国超
 * @date 2014年1月17日
 */
public class ImgViewerWindow extends BaseActivity{

	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.dialog_photo_entry);
		String url = getIntent().getStringExtra("url");
		if(url==null||url.length()==0){
			Toast.makeText(ImgViewerWindow.this, "不存在图片", Toast.LENGTH_LONG).show();
			finish();
			return;
		}
		CubeImageView img = (CubeImageView) this.findViewById(R.id.large_image);
		ImageLoader imageLoader = ImageLoaderFactory.create(ImgViewerWindow.this);
		App.loadImg(img, imageLoader, url);
		Toast toast = Toast.makeText(this, "点击图片即可返回", Toast.LENGTH_SHORT);
		toast.setGravity(Gravity.BOTTOM, 0, 0);
		toast.show();
		img.setOnClickListener(new View.OnClickListener() { // 点击返回
			public void onClick(View paramView) {
				ImgViewerWindow.this.finish();
			}
		});
	}

}
